It's me again, trying to figure out how to use pointers,
Im supposed to calculate alpha, beta and the lenght of c of a trianlge using a function (triangle_1)
and from what i think i'll have to use *pointers to get the values out of the function.
i tested the *cc, *alpha and *beta calculations outside a function and they seem to work
Code:
#include <stdio.h>#include <math.h>
#define TOTAL_DEG (180.0)
void triangle_1 (double a, double b,double c, double gamma, double *cc, double *alpha, double *beta)
{
*cc= sqrt((a*a+b*b-(2*a*b*cos(gamma))));
*alpha =(gamma)*(acos((double)(b*b +(c)*(c)- a*a)/(2.0*b*c)));
*beta = -gamma-*alpha+TOTAL_DEG;
}
int main()
{
double a,b,c,gamma,alpha,beta,result;
double tri;
printf("Bitte gib a, b und gamma eines Dreiecks ein\n");
scanf("%lf,%lf,%lf",&a,&b,&gamma);
prinf("a,b,c: %lf %lf %lf; gegenueber liegende Winkel: %lf %lf %lf",a,b,c,*alpha,*beta,gamma);
return 0;
}
}
thanks for the help o/
*edit, im unsure if im missing these to get the rad to degree or the other way around, i always hated trigonometry
double rad (double grad) {return (grad/45.) * atan(1.);}
double grad (double rad) {return (rad*45.) / atan(1.);}